// pages/more_job/more_job.js
var jobJsonData = require('../../data/job_data.js');
const $api = require('../../utils/api').API;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jobs:[]
  },

  // 工作详情
  job_details: function (e) {
    console.log(e)
    var arrayIndex = e.currentTarget.id;
    console.log(arrayIndex)
    // 把要传递的json对象转换成字符串
    var jobDetails = JSON.stringify(this.data.jobs[arrayIndex]);
    console.log(this.data.JobDataList);
    wx.navigateTo({
      url: '/pages/job_details/job_details?jobDetails=' + jobDetails
   });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {

    this.setData({
      JobDataList: jobJsonData.JobDataList
    });
    this.init();
  },

  init() {
    $api.getJobs().then(res => {
      console.log(res);
      this.setData({
        jobs:res
      })
    })
  }

  
})